package com.d0326;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestHashSet {
    public static void main(String[] args) {
        Set<Student>set=new HashSet<>();
        Student stu1 = new Student("Bright", 22, 100);
        Student stu2 = new Student("Win", 20, 95);
        Student stu3 = new Student("Jack", 25, 98);
        set.add(stu1);
        set.add(stu2);
        set.add(stu3);
        //set.add("111");
        //set.add("222");
        //set.add("333");
        //set.add("444");
        System.out.println("个数为:"+set.size());
        /*System.out.println(set.remove("333"));//删除333这个元素
        System.out.println(set.contains("111"));//判断111这个元素存不存在
         set.clear();
        System.out.println(set.size());
        System.out.println(set.isEmpty());*/
        Iterator<Student> iterator=set.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());

        }
    }
}
